(function($){ 
	$.fn.popeSlideLock = function(options){ 
		var defaults = { 
			close:false,
			callback:function(){}
		};
		var options = $.extend(defaults, options); 
		var objid = $(this).attr("id");
		if($("#gridlock_"+objid).length>0){
			$("#gridlock_"+objid).hide("blind",null,300,function(){
				$("#gridlock_"+objid).remove();
			});
			
			return;
		}
		if(options.close==true){
			$("#gridlock_"+objid).hide("blind",null,300,function(){
				$("#gridlock_"+objid).remove();
			});
			
			return;
			
		}

		var slidepwd="";
		var divstr = '<div id="gridlock_'+objid+'" class="gridlock" ><div class="lockitem" id="lockitem_0"></div><div class="lockitem" id="lockitem_1"></div><div class="lockitem" id="lockitem_2"></div><div class="lockitem" id="lockitem_3"></div><div class="lockitem" id="lockitem_4"></div><div class="lockitem" id="lockitem_5"></div><div class="lockitem" id="lockitem_6"></div><div class="lockitem" id="lockitem_7"></div><div class="lockitem" id="lockitem_8"></div><div class="lockitem" id="lockitem_9"></div><div class="lockitem" id="lockitem_a"></div><div class="lockitem" id="lockitem_b"></div><div class="lockitem" id="lockitem_c"></div><div class="lockitem" id="lockitem_d"></div><div class="lockitem" id="lockitem_e"></div><div class="lockitem" id="lockitem_f"></div>';
		var l = parseFloat($(this).offset().left);
		var t = parseFloat($(this).offset().top);
		var h = parseFloat($(this).css("height"));
		var w = parseFloat($(this).css("width"));

		$("body").append(divstr);

		
		

		$("#gridlock_"+objid).css("left",l+w+5);
		$("#gridlock_"+objid).css("top",t);


		start();
		$("#gridlock_"+objid).show("blind",null,300,null);


		

		function addslidepwd(obj){
			var objvalid = $(obj).attr("id").split("_")[1];
			if(slidepwd.indexOf(objvalid)!=-1){
				
				return;
			}
			slidepwd = slidepwd + "" + objvalid;
		}

		function start(){
			$(".lockitem").addClass("lockitemNotHover");

			$(".lockitem").draggable({
				containment:"#gridlock",
				cursor: "move",
				helper:"none",
				start:function(){
					$(".lockitem").hover(function(){
						$(this).removeClass("lockitemNotHover");
						$(this).addClass("lockitemOnHover");
						addslidepwd(this);
					},function(){
						
					});

					$(this).removeClass("lockitemNotHover");
					$(this).addClass("lockitemOnHover");
					addslidepwd(this);
					

				},
				stop:function(){
					$(".lockitem").unbind("hover");
					$(".lockitem").removeClass("lockitemOnHover");
					$(".lockitem").addClass("lockitemNotHover");

					options.callback(slidepwd);
					slidepwd = "";
				}
			});
		}


		this.each(function(){ 

			
		}); 
	};

})(jQuery); 